const state = {
  tablist: [
    {
      path: '/home',
      name: 'home',
      label: '首页',
    },
  ],
  // 当前路由对象
  currentMenu: null,
};
const mutations = {
  selectMenu(state, val) {
    if (val.name !== 'home') {
      state.currentMenu = val;
      const isexist = state.tablist.findIndex((item) => item.name === val.name);
      if (isexist == -1) {
        state.tablist.push(val);
      }
    } else {
      state.currentMenu = null;
    }
  },
  deleteTab(state, val) {
    state.tablist = state.tablist.filter((i) => i !== val);
    // const res = state.tablist.findIndex((i) => i === val);
    // if (res > -1) {
    //   state.tablist.splice(res, 1);
    // }
  },
};
export default {
  namespaced: true,
  state,
  mutations,
};
